package com.chengyu.core.controller.content;

import com.chengyu.core.controller.UserBaseController;
import com.chengyu.core.entity.CommonResult;
import com.chengyu.core.model.CmsFeedback;
import com.chengyu.core.service.content.FeedbackService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Api(tags = "FeedbackController", description = "意见反馈管理")
@Controller
@RequestMapping("/member")
public class FeedbackController extends UserBaseController {
	
	@Autowired
	private FeedbackService feedbackService;
	
	@ApiOperation(value = "添加修改意见")
	@ResponseBody
	@RequestMapping(value="/feedback/editSubmit", method=RequestMethod.POST)
	public CommonResult<String> add(CmsFeedback cmsFeedback) throws Exception {
		if(cmsFeedback.getId() != null && cmsFeedback.getId() > 0L) {
			feedbackService.editFeedback(cmsFeedback);
		}else{
			cmsFeedback.setPhone(getCurrentMember().getPhone());
			cmsFeedback.setMemberId(getCurrentMemberId());
			cmsFeedback.setMemberName(getCurrentMember().getNickname());
			feedbackService.addFeedback(cmsFeedback);
		}

		return CommonResult.success(null);
	}

}